#!/usr/bin/env python3
#-*- coding: utf-8 -*-

__auther_ = 'teffy'

'''
@filename enemy
@created on 2017-11-09
@poject:python-shoot-game
@auther:teffy
'''

import pygame
from pygame.sprite import Sprite

class Enemy(Sprite):
    def __init__(self,settings,screen):
        super(Enemy,self).__init__()
        self.screen = screen
        self.settings = settings

        self.image = pygame.image.load('imgs/alien.bmp')
        self.rect = self.image.get_rect()

        self.rect.x = self.rect.width
        self.rect.y = self.rect.height

        self.x = float(self.rect.x)

    def blitme(self):
        self.screen.blit(self.image,self.rect)

    def check_edges(self):
        screen_rect = self.screen.get_rect()
        if self.rect.right >= screen_rect.right:
            return True
        elif self.rect.left <= 0:
            return True
        else:
            return False

    def update(self):
        self.x += (self.settings.enemy_speed_factor * self.settings.enemy_move_direction)
        # if self.x >= self.settings.screen_width:
        #     self.x = 0
        #     self.rect.y += self.rect.height
        self.rect.x = self.x
